<?php


namespace app\xiangji\controller;


use app\common\helpers\Response;
use app\Request;
use app\xiangji\BaseController;
use app\xiangji\services\UserLoverService;
use app\xiangji\services\UserService;
use think\App;
use think\exception\ValidateException;

class UserLover extends BaseController
{
    private $userLoveService;

    public function __construct(UserLoverService $userLoveService)
    {
        $this->userLoveService = $userLoveService;
    }

    /**
     * @todo 获取分享恋人绑定
     * @return \think\response\Json
     */
    public function getLoverBindToken()
    {
        $result = $this->userLoveService->generateLoverBindToken();
        return $this->success($result);
    }

    /**
     * @todo 通过邀请token绑定恋人关系
     * @param Request $request
     * @return \think\response\Json
     * @throws \think\Exception
     */
    public function bindLoverByToken(Request $request)
    {
        $result = $this->userLoveService->bindLoverByToken($request->post('token'));
        return $this->success($result);
    }

    /**
     * @todo 解绑恋人关系
     * @return \think\response\Json
     * @throws \think\Exception
     */
    public function unbindLover()
    {
        $result = $this->userLoveService->unbindLover();
        return $this->success($result);
    }
}
